﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Base;
using Base.Commands;

namespace Imp.Controllers
{
    public static class KeyboardCommandList
    {
        public static void GenerateDefaultKeyCommands(ImpKeyboard keyboard)
        {
            // play / pause keycommands
            keyboard.Add(new KeyCommand() { Command = ImpCommand.Playpause, Key = Key.Space, NeedRelease = true });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.GlobalPlaypause, Key = Key.MediaPlayPause, NeedRelease = true, Anywhere = true, AllowedStyle = PlayerStyle.MediaPlayer });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.GlobalPlaypause, Key = Key.Pause, NeedRelease = true, Anywhere = true,ModifierKeys = ModifierKeys.Shift, AllowedStyle = PlayerStyle.MediaPlayer });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.Pause, Key = Key.MediaStop, NeedRelease = true, Anywhere = true, AllowedStyle = PlayerStyle.All });

            // rewind / fast forward
            keyboard.Add(new KeyCommand() { Command = ImpCommand.Fastforward, Key = Key.Right, NeedRelease = false });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.Rewind, Key = Key.Left, NeedRelease = false });

            // volume / mute keycommands
            keyboard.Add(new KeyCommand() { Command = ImpCommand.VolumeChange, Key = Key.Add, NeedRelease = false, Argument = 0.01 });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.VolumeChange, Key = Key.Subtract, NeedRelease = false, Argument = -0.01 });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.VolumeChange, Key = Key.Up, NeedRelease = false, ModifierKeys = ModifierKeys.Control, Argument = 0.01 });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.VolumeChange, Key = Key.Down, NeedRelease = false, ModifierKeys = ModifierKeys.Control, Argument = -0.01 });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.VolumeMute, Key = Key.M, NeedRelease = true });


            // Open previous / next keycommands
            keyboard.Add(new KeyCommand() { Command = ImpCommand.OpenNext, Key = Key.PageDown, NeedRelease = true });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.OpenPrev, Key = Key.PageUp, NeedRelease = true });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.OpenNext, Key = Key.Right, NeedRelease = true, ModifierKeys = ModifierKeys.Control });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.OpenPrev, Key = Key.Left, NeedRelease = true, ModifierKeys = ModifierKeys.Control });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.OpenNext, Key = Key.MediaNextTrack, NeedRelease = true, Anywhere = true, AllowedStyle = PlayerStyle.MusicPlayer });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.OpenPrev, Key = Key.MediaPreviousTrack, NeedRelease = true, Anywhere = true, AllowedStyle = PlayerStyle.MusicPlayer});
            keyboard.Add(new KeyCommand()
                         {
                             Command = ImpCommand.OpenNext,
                             Key = Key.Oem7,
                             NeedRelease = true,
                             Anywhere = true,
                             ModifierKeys = ModifierKeys.Control,
                             AllowedStyle = PlayerStyle.MediaPlayer
                         });
            keyboard.Add(new KeyCommand()
            {
                Command = ImpCommand.OpenPrev,
                Key = Key.Oem3,
                NeedRelease = true,
                Anywhere = true,
                ModifierKeys = ModifierKeys.Control,
                AllowedStyle = PlayerStyle.MediaPlayer
            });


            // panel and window keycommands
            keyboard.Add(new KeyCommand() { Command = ImpCommand.Exit, Key = Key.Escape, NeedRelease = true });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.Exit, Key = Key.F12, NeedRelease = true });

            keyboard.Add(new KeyCommand() { Command = ImpCommand.ToggleFullscreen, Key = Key.F11, NeedRelease = true });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.PlayerMinimize, Key = Key.F10, NeedRelease = true });

            keyboard.Add(new KeyCommand() { Command = ImpCommand.PanelOpen, Key = Key.F6, NeedRelease = true });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.PanelSettings, Key = Key.F7, NeedRelease = true });
            keyboard.Add(new KeyCommand() { Command = ImpCommand.PanelPlaylist, Key = Key.F8, NeedRelease = true });

            keyboard.Add(new KeyCommand() { Command = ImpCommand.TogglePanels, Key = Key.Space, ModifierKeys = ModifierKeys.Control, NeedRelease = true });

            // copy name text
            keyboard.Add(new KeyCommand() {Command = ImpCommand.CopyName, Key = Key.C, ModifierKeys = ModifierKeys.Control});


            // play random
            keyboard.Add(new KeyCommand() { Command = ImpCommand.OpenRandom, Key = Key.R, ModifierKeys = ModifierKeys.Control });
        }
    }
}
